﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace 召唤师技能计时器
{
    public partial class LoginForm : Form
    {
        public LoginForm()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            //ActiveForm.TransparencyKey = Color.Red;
        }

        #region 时间变量
        private int gameSec = 0;
        private int topSec = 300;
        private int jugSec = 300;
        private int midSec = 300;
        private int adcSec = 300;
        private int supSec = 300;
        #endregion

        #region 计时器Tick
        private void timerTop_Tick(object sender, EventArgs e)
        {
            topSec--;
            timeOfTop.Text = (topSec / 60).ToString() + ":" + (topSec % 60).ToString().PadLeft(2, '0');
            if(20 == topSec)
            {
                
            }
            if(0 == topSec)
            {
                topSec = 300;
                timerTop.Enabled = false;
                timeOfTop.Text = "Done";
            }
        }

        private void timerJug_Tick(object sender, EventArgs e)
        {
            jugSec--;
            timeOfJug.Text = (jugSec / 60).ToString() + ":" + (jugSec % 60).ToString().PadLeft(2, '0');
            if (20 == jugSec)
            {

            }
            if (0 == jugSec)
            {
                jugSec = 300;
                timerJug.Enabled = false;
                timeOfJug.Text = "Done";
            }
        }

        private void timerMid_Tick(object sender, EventArgs e)
        {
            midSec--;
            timeOfMid.Text = (midSec / 60).ToString() + ":" + (midSec % 60).ToString().PadLeft(2, '0');
            if(20 == midSec)
            {

            }
            if(0 == midSec)
            {
                midSec = 300;
                timerMid.Enabled = false;
                timeOfMid.Text = "Done";
            }
        }

        private void timerADC_Tick(object sender, EventArgs e)
        {
            adcSec--;
            timeOfADC.Text = (adcSec / 60).ToString() + ":" + (adcSec % 60).ToString().PadLeft(2, '0');
            if(20 == adcSec)
            {

            }
            if(0 == adcSec)
            {
                adcSec = 300;
                timerADC.Enabled = false;
                timeOfADC.Text = "Done";
            }
        }

        private void timerSup_Tick(object sender, EventArgs e)
        {
            supSec--;
            timeOfSup.Text = (supSec / 60).ToString() + ":" + (supSec % 60).ToString().PadLeft(2, '0');
            if (20 == supSec)
            {

            }
            if (0 == supSec)
            {
                supSec = 300;
                timerSup.Enabled = false;
                timeOfSup.Text = "Done";
            }
        }
        #endregion

        #region 开始计时按钮
        private void buttonTop_Click(object sender, EventArgs e)
        {
            if (false == timerTop.Enabled)
                timerTop.Enabled = true;
            else topSec = 300;
        }

        private void buttonJug_Click(object sender, EventArgs e)
        {
            if (false == timerJug.Enabled)
                timerJug.Enabled = true;
            else jugSec = 300;
        }

        private void buttonMid_Click(object sender, EventArgs e)
        {
            if (false == timerMid.Enabled)
                timerMid.Enabled = true;
            else midSec = 300;
        }

        private void buttonADC_Click(object sender, EventArgs e)
        {
            if (false == timerADC.Enabled)
                timerADC.Enabled = true;
            else adcSec = 300;
        }

        private void buttonSup_Click(object sender, EventArgs e)
        {
            if (false == timerSup.Enabled)
                timerSup.Enabled = true;
            else supSec = 300;
        }
        #endregion

        /// <summary>
        /// 复制消息到剪贴板
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonCopy_Click(object sender, EventArgs e)
        {
            string text1 = (true == timerTop.Enabled) ? (((gameSec + topSec) / 60).ToString() + ":"+ ((gameSec + topSec) % 60).ToString().PadLeft(2,'0') + "Top ") : "";
            string text2 = (true == timerJug.Enabled) ? (((gameSec + jugSec) / 60).ToString() + ":" + ((gameSec + jugSec) % 60).ToString().PadLeft(2, '0') + "Jug ") : "";
            string text3 = (true == timerMid.Enabled) ? (((gameSec + midSec) / 60).ToString() + ":" + ((gameSec + midSec) % 60).ToString().PadLeft(2, '0') + "Mid ") : "";
            string text4 = (true == timerADC.Enabled) ? (((gameSec + adcSec) / 60).ToString() + ":" + ((gameSec + adcSec) % 60).ToString().PadLeft(2, '0') + "AD ") : "";
            string text5 = (true == timerSup.Enabled) ? (((gameSec + supSec) / 60).ToString() + ":" + ((gameSec + supSec) % 60).ToString().PadLeft(2, '0') + "Sup ") : "";
            string text = text1 + text2 + text3 + text4 + text5;
            text = text.TrimEnd(' '); 
            if (!text.Equals(""))
            {
                Clipboard.SetText(text);
            }
            else Clipboard.SetText(" ");
        }
        /// <summary>
        /// 开始游戏
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonGo_Click(object sender, EventArgs e)
        {
            timerGame.Enabled = true;
            loT.Visible = true;
            loJ.Visible = true;
            loM.Visible = true;
            loA.Visible = true;
            loS.Visible = true;

            timeOfTop.Visible = true;
            timeOfJug.Visible = true;
            timeOfMid.Visible = true;
            timeOfADC.Visible = true;
            timeOfSup.Visible = true;

            buttonTop.Visible = true;
            buttonJug.Visible = true;
            buttonMid.Visible = true;
            buttonADC.Visible = true;
            buttonSup.Visible = true;

            buttonCopy.Visible= true;

            buttonGo.Visible = false;
        }
        /// <summary>
        /// 游戏时间
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timerGame_Tick(object sender, EventArgs e)
        {
            gameSec++;
        }
    }
}
